#pragma once

#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/epoll.h>
#include <unistd.h>
#include <string>
#include <vector>
#include "Public.h"
#include "Socket.h"

using namespace std;

class TcpConnect {
public:
	TcpConnect():_socketFd(-1), _status(NOTUSE) {
	}
	TcpConnect(int fd, Address addr):_socketFd(fd), _peerAddr(addr), _status(ConnectStatus::READY) {
	}			//set the Connect Time
	~TcpConnect(){};

	int read(void *buf, int len, int timeout);
	int write(void *buf, int len, int timeout);
	int close();
	bool alive();

	struct timeval getConnectTime() {
		return _connectTime;
	}
	struct timeval getLastActiveTime() {
		return _lastActiveTime;
	}

	Address & getPeerAddr() {
		return _peerAddr;
	}
	int getSocketFd() {
		return _socketFd;
	}

	ConnectStatus getConnectStatus() {
		return _status;
	}

	void setConnectTime(struct timeval t) {
		_connectTime = t;
	}
	void setLastActiveTime(struct timeval t) {
		_lastActiveTime = t;
	}

	void setPeerAddr(Address addr) {
		_peerAddr = addr;
	}
	void setConnectStatus(ConnectStatus s) {
		_status = s;
	}
private:
	struct timeval _connectTime;
	struct timeval _lastActiveTime;
	Address _peerAddr;
	Address _addr;
	int _socketFd;
	ConnectStatus _status;
};

